package zhtt.example.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.reactive.function.client.WebClient;
import zhtt.example.predicate.TimeAfterRoutePredicateFactory;

/**
 * Created by zhaoq on   2024/9/19 14:10
 **/
@Slf4j
@Configuration
public class GatewayConfig {

    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    /**
     * 用于发送http请求
     * @return
     */
    @Bean
    public WebClient webClient() {
        return WebClient.builder().build();
    }

    /**
     * 用于获取微服务
     * @return
     */
    @Bean
    @LoadBalanced
    public WebClient.Builder loadBalancedWebClientBuilder() {
        return WebClient.builder();
    }

/*    @Bean
    public TimeAfterRoutePredicateFactory timeAfterPredicateFactory() {
        return new TimeAfterRoutePredicateFactory();
    }*/
}
